from src.Car import Car


class Truck(Car):

    def __init__(self, io_strategy, num):
        super().__init__(io_strategy, num)
        self.capacity = None
        self.type = "truck"
        self.set_capacity()

    def set_capacity(self):
        self.capacity = self.io_strategy.input("capacity")

    def __str__(self):
        prefix = super().__str__()
        return prefix + f"\nВместимость: {self.capacity}"

    def edit(self):
        self.set_model()
        self.set_year()
        self.set_capacity()

    def __keys__(self):
        k = super().__keys__()
        k.append("capacity")
        return k

    def asdict(self):
        s = super().asdict()
        s["capacity"] = self.capacity
        s["type"] = self.type
        return s

    def to_json(self):
        j = super().to_json()
        j["capacity"] = self.capacity
        j["type"] = self.type
        return j
